package com.china08.yxyapi.api.manage.stu.myclass.moments;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.model.YxyApiRespModel;
import com.china08.yxyapi.repository.mg.moments.YxyMomentsRepository;

/**
 * 班级圈--家长--删除
 * 
 * @author LiuWeidong
 *
 */
@CrossOrigin
@RestController
public class MomentsStuDelComment extends YxyApiBaseController {

    @Autowired
    private YxyMomentsRepository yxyMomentsRepository;

    @RequestMapping(value = "/api_yw/manage/stu/moments/del/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public RespModel precess(HttpServletRequest request, HttpServletResponse response, RespModel respModel,
            @PathVariable("id") String id) {

        String userId = getProfile(request, response).getId();
        // YxyProfile yxyProfile = getProfile(request, response);
        // String userId = yxyProfile.getId();

        yxyMomentsRepository.deleteByIdAndSenderId(id, userId);
        respModel = new RespModel();
        respModel.setMessage("删除成功");
        return respModel;
    }

    protected static class RespModel extends YxyApiRespModel {
    }
}
